/*
 * @Author       : wfl
 * @LastEditors: ww
 * @description  :
 * @updateInfo   :
 * @Date         : 2022-12-15 09:52:50
 * @LastEditTime: 2023-05-23 17:41:03
 */
import type { ISearchForm } from '@/global/enums/search'
import { getType } from '@/MainApp/apis/manage-design'
export const useFields = async () => {
  const defKeys = useTableKey()
  const typeList = ref([])
  const { success, data } = await getType()
  if (success) {
    typeList.value = data.map((item: any) => {
      return {
        ...item,
        label: item.description,
        value: item.type
      }
    })
  }

  const fields: ISearchForm[] = [{
    key: 'name',
    value: '',
    label: '名称',
    show: true,
    minWidth: 100,
    search: true
  }, {
    key: 'scaffoldTypeName',
    value: '',
    type: 'el-select',
    options: typeList.value,
    label: '设计类型',
    show: true,
    minWidth: 120,
    search: true
  }, {
    key: 'description',
    value: '',
    label: '描述',
    show: true
  }, {
    key: 'createName',
    value: '',
    label: '创建人',
    show: true,
    minWidth: 100,
    search: true
  },
  ...defKeys,
  {
    key: '',
    label: '操作',
    show: true,
    width: 148,
    tableSlot: 'operate',
    fixed: 'right',
    showOverflowTooltip: false
  }
  ]

  return fields
}
